package cn.qm.service;


import cn.qm.dao.RoomMapper;
import cn.qm.pojo.Room;
import org.springframework.data.domain.Page;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.Date;
import java.util.List;
import java.util.Map;

/**
* Created by shang-pc on 2018/5/15.
*/
@RestController
public class RoomClient {
    @Resource
    private RoomMapper roomMapper;
    @RequestMapping(value = "/getRoomById", method = RequestMethod.POST)
    public Room getRoomById(@RequestParam Long id) throws Exception {
        return roomMapper.getRoomById(id);
    }

    @RequestMapping(value = "/getRoomListByMap", method = RequestMethod.POST)
    public List<Room> getRoomListByMap(@RequestBody Map<String, Object> param) throws Exception {
        return roomMapper.getRoomListByMap(param);
    }

    @RequestMapping(value = "/getRoomCountByMap", method = RequestMethod.POST)
    public Integer getRoomCountByMap(@RequestBody Map<String, Object> param) throws Exception {
        return roomMapper.getRoomCountByMap(param);
    }

    @RequestMapping(value = "/qmtxAddRoom", method = RequestMethod.POST)
    public Integer qmtxAddRoom(@RequestBody Room room) throws Exception {
        room.setCreatedTime(new Date());
        return roomMapper.insertRoom(room);
    }

    @RequestMapping(value = "/qmtxModifyRoom", method = RequestMethod.POST)
    public Integer qmtxModifyRoom(@RequestBody Room room) throws Exception {
        room.setUpdatedTime(new Date());
        return roomMapper.updateRoom(room);
    }

    @RequestMapping(value = "/qmtxDeleteRoomById", method = RequestMethod.POST)
    public Integer qmtxDeleteRoomById(@RequestParam Long id) throws Exception {
        return roomMapper.deleteRoomById(id);
    }

    @RequestMapping(value = "/queryRoomPageByMap", method = RequestMethod.POST)
    public Page<Room> queryRoomPageByMap(@RequestBody Map<String, Object> param, Integer pageNo, Integer pageSize) throws Exception {
        return null;
    }
}
